// Learn cc.Class:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const GameDataManger = require("../GameDataManger");

cc.Class({
    extends: cc.Component,

    properties: {
        progress1:{     //音乐
            default:null,
            type:cc.Slider
        },

        progress2:{     //音效
            default:null,
            type:cc.Slider
        },
    },

    onEnable(){
        this.progress1.progress = GameDataManger.musicVal/1;

        this.progress2.progress = GameDataManger.soundVal/1;

        this.progress1.node.children[1].width = 400 * GameDataManger.musicVal;

        this.progress2.node.children[1].width = 400 * GameDataManger.soundVal;
    },

    refreshgame(){
        GameDataManger.musicVal = this.progress1.progress;

        GameDataManger.soundVal = this.progress2.progress;

        this.progress1.node.children[1].width = 400 * GameDataManger.musicVal;

        this.progress2.node.children[1].width = 400 * GameDataManger.soundVal;

        cc.systemEvent.emit(GameDataManger.musicRefresh);
    },

    onDisable(){
        cc.systemEvent.emit('saveUserData');
    },

    // update (dt) {},
});
